// import Keys from "@/constant/key";
import Cookies from "js-cookie";
//加密工具
import CryptoJS from 'crypto-js';

export const getLanguage = () => Cookies.get('languageToChange');
export const setLanguage = (language) => {
  Cookies.set('languageToChange', language)
};
export const removeLanguage = () => {
  Cookies.remove('languageToChange')
}


export const getToken = () => Cookies.get('token');
export const setToken = (token) => {
  Cookies.set('token', token)
};
export const removeToken = () => {
  Cookies.remove('token')
}

export const getUserInfo = () => {
  let res = Cookies.get('userInfo')
  let bytes = CryptoJS.AES.decrypt(res, 'userInfo')
  res = JSON.parse(bytes.toString(CryptoJS.enc.Utf8))
  return res
};
export const setUserInfo = (data) => {
  let res = CryptoJS.AES.encrypt(JSON.stringify(data), 'userInfo').toString()
  Cookies.set('userInfo', res)
}
export const removeUserInfo = () => {
  Cookies.remove('userInfo')
}